﻿# CMakeList.txt: libcpps 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required (VERSION 3.8)

# 将源代码添加到此项目的可执行文件。
AUX_SOURCE_DIRECTORY(${PROJECT_SOURCE_DIR}/src  SRC_LIST)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include .)

file(GLOB_RECURSE CURRENT_HEADERS  ${PROJECT_SOURCE_DIR}/include/*.h)
source_group("Include" FILES ${CURRENT_HEADERS}) 

IF (WINDOWS)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)


set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)

ELSE ()

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)

ENDIF ()

ADD_LIBRARY (cpps STATIC ${SRC_LIST} ${CURRENT_HEADERS})

IF (LINUX)
	target_link_libraries(${PROJECT_NAME} -lrt -ldl -lm -lpthread)
		
	install(FILES ${CURRENT_HEADERS} DESTINATION include)

	install(TARGETS cpps
	RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib)

ELSEIF(MACOS)
	target_link_libraries(${PROJECT_NAME} -ldl -lm -lpthread)
		
	install(FILES ${CURRENT_HEADERS} DESTINATION include)

	install(TARGETS cpps
	RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib)
ENDIF ()
